package leaveSystem.bizlogic;

import java.sql.Connection;

import java.util.List;

import leaveSystem.dao.DAOFactory;

import leaveSystem.dao.EmployeeWorkscheduleDAO;

import leaveSystem.model.EmployeeWorkschedule;
import leaveSystem.model.CompensationTracking;
import leaveSystem.dao.Compensation_TrackingDao;

public class WorkScheduleManager {
	private EmployeeWorkschedule EMentity;
	private EmployeeWorkscheduleDAO EmployeeWorkscheduleDAO;
	private CompensationTracking CTentity;
	private Compensation_TrackingDao Compensation_TrackingDao;

	private static Connection conn;

	public WorkScheduleManager() {
		EmployeeWorkscheduleDAO = DAOFactory.loadInstance()
				.getEmployeeWorkscheduleDAO();
		conn = DAOFactory.getDatabaseConnection();
		Compensation_TrackingDao = DAOFactory.loadInstance()
				.getCompensation_TrackingDao();
		conn = DAOFactory.getDatabaseConnection();

	}

	public void insertEmployeeWorkschedule(EmployeeWorkschedule valueObject) {
		try {
			EmployeeWorkscheduleDAO.insertEmployeeWorkschedule(conn,valueObject);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateEmployeeWorkschedule(EmployeeWorkschedule obj) {
		try {
			EmployeeWorkscheduleDAO.updateEmployeeWorkschedule(conn, obj);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void deleteEmployeeWorkschedule(Connection conn,
			EmployeeWorkschedule valueObject) {
		try {
			EmployeeWorkscheduleDAO.deleteEmployeeWorkschedule(conn,valueObject);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public List<EmployeeWorkschedule> FindEmployeeworkschedule(
			EmployeeWorkschedule obj) {
		/*
		 * LeaveManager lm=new LeaveManager();
		 * 
		 * if(EMentity.getCompensationHours()>4) { lm. }
		 */
		List<EmployeeWorkschedule> EmpRec = null;
		try {
			EmployeeWorkscheduleDAO.findEmployeeWorkschedule(conn, obj);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return EmpRec;

	}

	public List<CompensationTracking> loadAll(CompensationTracking obj) {
		List<CompensationTracking> loaddata = null;
		{
			try {
				loaddata = Compensation_TrackingDao.loadall(conn);

			} catch (Exception e) {
				e.printStackTrace();
			}
			return loaddata;
		}

	}

	public void save(CompensationTracking valueObject) {
		try {
			Compensation_TrackingDao.save(conn, valueObject);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void delete(Connection conn, CompensationTracking valueObject) {
		try {
			Compensation_TrackingDao.delete(conn, valueObject);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}